package Draw;

public class Draw {
    private int height;

    // 构造函数，用于初始化高度，并进行合法性校验
    public Draw(int height) {
        if (height < 3) {
            System.out.println("高度至少要为3行哦∩o∩");
            System.exit(1);
        }
        this.height = height;
    }

    // 绘制三角形
    public void triangle() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制矩形
    public void rectangle() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制平行四边形
    public void parallelogram() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height - i; j++) {
                System.out.print(" ");
            }
            for (int k = 0; k < height; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}